{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.ensemble import RandomForestClassifier\n",
    "from sklearn.datasets import make_classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "X, y = make_classification(n_samples=1000, n_features=4, n_informative=2, n_redundant=0, random_state=0, shuffle=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "clf = RandomForestClassifier(n_estimators=100, max_depth=2, random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "clf.fit(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(clf.feature_importances_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(clf.predict([[0, 0, 0, 0]]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.ensemble import RandomForestRegressor\n",
    "from sklearn.datasets import make_regression\n",
    "X, y = make_regression(n_features=4, n_informative=2, random_state=0,shuffle=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "regr = RandomForestRegressor(max_depth=2, random_state=0, n_estimators=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "regr.fit(X,y)\n",
    "print(regr.predict([[0,0,0,0]]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "N = 1000\n",
    "p = 100\n",
    "def genXY(N, p):\n",
    "    X = np.random.rand(N*p).reshape(N, p)\n",
    "    y = 10 * np.exp(-2*np.sum(X[:,0:5]**2, axis = 1)) + np.sum(X[:,5:35], axis = 1) + np.random.normal(0, 1.3, N)\n",
    "    return X, y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "X, y = genXY(1000,100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.ensemble import RandomForestRegressor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "GradientBoostingRegressor(alpha=0.9, criterion='friedman_mse', init=None,\n",
       "             learning_rate=0.01, loss='ls', max_depth=3, max_features=None,\n",
       "             max_leaf_nodes=None, min_impurity_decrease=0.0,\n",
       "             min_impurity_split=None, min_samples_leaf=1,\n",
       "             min_samples_split=2, min_weight_fraction_leaf=0.0,\n",
       "             n_estimators=2500, n_iter_no_change=None, presort='auto',\n",
       "             random_state=None, subsample=1, tol=0.0001,\n",
       "             validation_fraction=0.1, verbose=0, warm_start=False)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rf = RandomForestRegressor(max_depth=2, random_state=0, n_estimators=2500)\n",
    "gbm1 = GradientBoostingRegressor(n_estimators=2500, learning_rate=0.01, subsample=1)\n",
    "gbm1.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RandomForestRegressor(bootstrap=True, criterion='mse', max_depth=2,\n",
       "           max_features='auto', max_leaf_nodes=None,\n",
       "           min_impurity_decrease=0.0, min_impurity_split=None,\n",
       "           min_samples_leaf=1, min_samples_split=2,\n",
       "           min_weight_fraction_leaf=0.0, n_estimators=2500, n_jobs=None,\n",
       "           oob_score=False, random_state=0, verbose=0, warm_start=False)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rf.fit(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mse(regr):\n",
    "    X_test, y_test = genXY(500, 100)\n",
    "    y_pred = regr.predict(X_test)\n",
    "    return np.mean((y_pred - y_test)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.26315845952546"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse(rf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.ensemble import GradientBoostingRegressor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "res = np.empty([4, 5])\n",
    "for i in range(5):\n",
    "    gbm1 = GradientBoostingRegressor(n_estimators=500*(1+i), learning_rate=0.01, subsample=1)\n",
    "    gbm1.fit(X, y)\n",
    "    gbm2 = GradientBoostingRegressor(n_estimators=500*(1+i), learning_rate=0.01, subsample=0.1)\n",
    "    gbm2.fit(X, y)\n",
    "    bs1, lasso1 = ISLE(X, y, model = \"GB\", n_est = 500*(1+i))\n",
    "    bs2, lasso2 = ISLE(X, y, model = \"RF\", n_est = 500*(1+i))\n",
    "    res[0, i] = mse(gbm1)\n",
    "    res[1, i] = mse(gbm2)\n",
    "    res[2, i] = mse_isle(bs1, lasso1)\n",
    "    res[3, i] = mse_isle(bs2, lasso2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ISLE(X, y, eta = 0.5, nu = 0.1, M = 10, model = \"GB\", n_est = 500):\n",
    "    N = len(X)\n",
    "    # step 1\n",
    "    f_hat = np.repeat(np.mean(y), N)\n",
    "    bs = [None] * M\n",
    "    for m in range(M):\n",
    "        Sm_idx = np.random.choice(N, int(eta*N), replace = False)\n",
    "        if model == \"GB\":\n",
    "            bs[m] = GradientBoostingRegressor(n_estimators=n_est, learning_rate=0.01)\n",
    "        else:\n",
    "            bs[m] = RandomForestRegressor(random_state=0, n_estimators=n_est)\n",
    "        bs[m].fit(X[Sm_idx], y[Sm_idx] - f_hat[Sm_idx])\n",
    "        f_hat = f_hat + nu * bs[m].predict(X)\n",
    "    # step 2\n",
    "    lasso = Lasso(alpha = 0.1)\n",
    "    Tx = np.empty([N, M])\n",
    "    for i in range(M):\n",
    "        Tx[:,i] = bs[i].predict(X)\n",
    "    lasso.fit(Tx, y)\n",
    "    return bs, lasso"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mse_isle(bs, lasso):\n",
    "    M = len(bs)\n",
    "    X_test, y_test = genXY(500, 100)\n",
    "    Tx = np.empty([len(X_test), M])\n",
    "    for i in range(M):\n",
    "        Tx[:, i] = bs[i].predict(X_test)\n",
    "    y_pred = lasso.predict(Tx)\n",
    "    return np.mean((y_pred - y_test)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs, lasso = ISLE(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.7838419536617893"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_isle(bs, lasso)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import Lasso"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "lasso = Lasso(alpha=0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Lasso(alpha=0.1, copy_X=True, fit_intercept=True, max_iter=1000,\n",
       "   normalize=False, positive=False, precompute=False, random_state=None,\n",
       "   selection='cyclic', tol=0.0001, warm_start=False)"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lasso.fit(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([16.11963328, 15.90659572, 16.09956959, 15.80812887, 15.94646844,\n",
       "       16.10173761, 16.18959057, 16.2608489 , 15.63376061, 15.53285881,\n",
       "       16.11347873, 16.09418098, 15.74903257, 15.64689923, 16.19212549,\n",
       "       16.07858233, 15.7814767 , 15.96743905, 15.93585248, 15.94528023,\n",
       "       16.25631161, 15.55308676, 15.99240576, 15.98074183, 15.80278877,\n",
       "       15.47398886, 15.71190252, 16.26247666, 15.85774815, 15.75119578,\n",
       "       15.76947791, 15.68952973, 15.72934697, 16.01947211, 15.60091199,\n",
       "       15.78829114, 15.71435376, 16.22997147, 16.11673847, 15.68506155,\n",
       "       15.7420122 , 15.66014509, 15.40484804, 15.69442619, 15.80642629,\n",
       "       15.97531893, 15.83585692, 15.9550448 , 15.78272366, 15.67924604,\n",
       "       15.97635508, 16.00130144, 15.70796899, 15.45433448, 15.98993201,\n",
       "       16.03347767, 16.04550161, 15.73203945, 15.50852142, 15.46085804,\n",
       "       15.66386228, 15.90474803, 15.41145016, 15.81288178, 15.82982495,\n",
       "       16.27315581, 16.08020934, 15.91556429, 15.48020588, 16.32022123,\n",
       "       15.64183055, 15.77398958, 16.20319329, 15.87122065, 15.62473369,\n",
       "       15.77496945, 16.18715586, 15.83229343, 15.91741194, 15.93893343,\n",
       "       15.75153821, 15.92246735, 15.86155687, 15.69974706, 15.84340713,\n",
       "       16.11754096, 15.59114602, 15.58247755, 15.74045041, 15.81602297,\n",
       "       16.23001414, 15.78946737, 15.88945585, 16.12495778, 15.87471982,\n",
       "       16.05204121, 15.61551506, 16.20973379, 15.48745914, 15.76269441,\n",
       "       15.44491052, 15.63880596, 15.79318589, 15.7792397 , 15.82576063,\n",
       "       15.7053863 , 15.78810891, 15.70872718, 16.11020365, 16.04696119,\n",
       "       15.87673738, 15.76468137, 15.92660008, 15.77727884, 16.01661741,\n",
       "       15.50466208, 15.93046934, 15.62557361, 15.62143937, 15.78487911,\n",
       "       15.87847942, 15.69086623, 15.57407918, 15.30750508, 16.01267197,\n",
       "       16.13066407, 16.0572455 , 16.07884988, 15.96621152, 15.40021853,\n",
       "       15.92614802, 15.8372957 , 15.41466158, 15.98951305, 15.8754421 ,\n",
       "       15.4694077 , 15.94954897, 15.6600031 , 15.96736999, 15.57735799,\n",
       "       15.48547766, 15.47486165, 15.38876514, 15.91709133, 15.8252942 ,\n",
       "       15.99629604, 15.53701141, 15.84331077, 15.82896775, 15.96042979,\n",
       "       15.72642615, 15.93846672, 16.17506643, 16.02758416, 15.9198451 ,\n",
       "       16.19539473, 15.70829287, 15.76726675, 15.76561619, 15.88373029,\n",
       "       15.6852372 , 16.10042861, 16.07627223, 15.75935529, 15.33072475,\n",
       "       15.80561435, 15.73125891, 16.1436118 , 15.62350066, 16.02049186,\n",
       "       15.79497617, 16.01774255, 15.87320787, 15.89336942, 16.22452281,\n",
       "       15.94951012, 15.99362327, 15.77756315, 16.14155444, 16.03611437,\n",
       "       15.96237843, 16.11068722, 15.55661956, 15.73388908, 15.97556844,\n",
       "       15.96124495, 15.93690028, 16.33832348, 15.54323158, 16.17095891,\n",
       "       15.87352433, 15.83518063, 15.55330113, 16.24533781, 16.16924985,\n",
       "       16.06340899, 15.95652533, 16.05142233, 15.7337305 , 15.54262888,\n",
       "       15.79148166, 15.79437718, 16.18360062, 15.88078437, 16.0500594 ,\n",
       "       15.9117171 , 15.83210151, 15.79872303, 15.90783246, 15.77727421,\n",
       "       15.43419682, 15.70021012, 15.3120226 , 15.95880038, 15.41771822,\n",
       "       15.84780471, 16.14628127, 15.95659989, 15.50741248, 15.96153257,\n",
       "       15.88427127, 15.48542649, 16.0126373 , 15.99267706, 15.53787887,\n",
       "       16.27990178, 15.84931923, 15.8258542 , 15.82920166, 16.01905806,\n",
       "       15.406606  , 15.74607619, 15.91142668, 15.59640871, 15.82735049,\n",
       "       15.74821922, 15.76085248, 15.65148709, 15.97573248, 15.98920292,\n",
       "       15.34004012, 15.65611348, 15.57809608, 15.50209473, 15.7658619 ,\n",
       "       15.73330361, 15.74004792, 15.75522334, 15.76260228, 15.34266733,\n",
       "       15.76255979, 15.95493921, 16.12513786, 15.91580901, 15.93654041,\n",
       "       15.62397828, 15.99222384, 15.76770907, 16.25773715, 15.92617534,\n",
       "       15.70307016, 15.57485862, 15.72414308, 16.14487843, 15.75128551,\n",
       "       15.25824515, 15.73256399, 15.93146896, 15.98738625, 16.16413617,\n",
       "       15.9133168 , 15.95885517, 15.51523778, 15.91933261, 16.40460841,\n",
       "       16.21010033, 16.19552422, 15.492881  , 15.71447215, 15.56141475,\n",
       "       15.96280973, 16.19479038, 15.78020685, 16.05507666, 16.11161323,\n",
       "       15.61462731, 16.05838796, 15.74095863, 15.71078893, 15.95339873,\n",
       "       15.89719906, 16.28359752, 15.63686615, 15.94410087, 15.60200881,\n",
       "       15.90020336, 15.74753953, 15.98373963, 16.12025092, 15.70287958,\n",
       "       15.65354406, 15.83271689, 15.70162699, 15.97927683, 15.75606837,\n",
       "       15.94916694, 15.96436435, 15.39979277, 15.76385496, 15.58039046,\n",
       "       15.96284726, 15.71225924, 16.06664019, 15.70035563, 15.82476492,\n",
       "       15.37293413, 15.71628655, 15.52153016, 15.89956739, 15.81577347,\n",
       "       15.4163301 , 15.53338636, 15.91079977, 15.48741112, 15.74075593,\n",
       "       15.86633477, 15.99730523, 15.9241076 , 15.61435176, 15.45923034,\n",
       "       15.63389725, 15.8530874 , 15.76727692, 15.36489907, 15.31133501,\n",
       "       15.87069041, 15.70703369, 15.73489451, 16.06532733, 15.95389654,\n",
       "       16.27166261, 15.71359852, 15.86970861, 15.93080096, 15.65976483,\n",
       "       15.87538387, 15.73222285, 15.79261624, 15.70588089, 16.22586542,\n",
       "       15.98024918, 15.82577175, 15.68821717, 15.66051632, 15.92733777,\n",
       "       15.67191055, 16.20133121, 15.83896778, 15.73509018, 15.93607061,\n",
       "       15.79514996, 15.64155811, 15.96370287, 15.52882984, 15.58018124,\n",
       "       16.05444925, 15.89176257, 15.82904066, 15.91598898, 15.96024477,\n",
       "       15.44531742, 15.89229447, 16.17526353, 15.54815616, 16.04358702,\n",
       "       16.09508434, 16.01679972, 15.40094993, 15.36735435, 15.60819519,\n",
       "       15.73800204, 15.62374629, 15.81871821, 16.00934863, 15.81151598,\n",
       "       16.27424067, 15.78947538, 15.69181729, 15.80081877, 15.59951086,\n",
       "       15.97462443, 15.77594646, 15.74566863, 16.03675917, 15.22984212,\n",
       "       15.847277  , 15.73743027, 15.32692989, 15.79936102, 15.7442392 ,\n",
       "       15.94054645, 15.67814167, 15.52748933, 15.58039081, 16.22150921,\n",
       "       15.95894379, 15.61158143, 15.47421617, 16.16192168, 16.01430476,\n",
       "       15.67718386, 16.01119393, 15.79948766, 15.57917651, 15.64755327,\n",
       "       16.00035139, 15.54170289, 15.2746594 , 16.09293068, 16.01972873,\n",
       "       15.89778341, 15.80436556, 15.56418548, 16.01532609, 15.9375836 ,\n",
       "       15.99440827, 16.10046886, 15.41350525, 15.92989899, 16.13395959,\n",
       "       16.09150661, 15.57576251, 15.46399411, 15.5100638 , 15.92307035,\n",
       "       15.59250384, 15.54716505, 15.74488543, 15.95977187, 15.59112226,\n",
       "       16.33412772, 15.9173099 , 15.87617143, 16.14919794, 15.78702469,\n",
       "       16.14484586, 15.71310638, 15.73194678, 15.87281522, 15.635946  ,\n",
       "       15.74483619, 15.82450954, 15.47598414, 15.4464049 , 15.61793151,\n",
       "       15.85325995, 15.90811898, 15.67093804, 15.74553169, 16.0701209 ,\n",
       "       15.72910566, 15.86292307, 15.57824883, 15.93595779, 15.86161654,\n",
       "       15.63009938, 15.57998711, 15.7208636 , 15.80668623, 15.91786953,\n",
       "       16.06339313, 15.54311799, 15.76137936, 15.6708105 , 15.71568155,\n",
       "       15.88704438, 16.28642558, 16.30984975, 15.80535125, 16.36578343,\n",
       "       15.89680831, 15.57427468, 15.72719156, 15.82181073, 16.17015253,\n",
       "       16.00277185, 16.14338874, 15.88914972, 15.76932262, 15.75756038,\n",
       "       16.00604663, 16.10901051, 15.92832572, 15.43453078, 16.3612323 ,\n",
       "       15.66877401, 16.39640913, 16.05744833, 15.76371546, 15.65318479,\n",
       "       16.02392986, 15.56734412, 15.67776104, 15.78331613, 16.13187135,\n",
       "       15.57714686, 15.82209037, 16.26414965, 15.95627346, 15.81273363,\n",
       "       15.92924688, 15.68235536, 16.28307698, 15.65125441, 15.87874226,\n",
       "       15.5980154 , 15.97866876, 15.8821378 , 16.12448329, 15.29059664,\n",
       "       15.55602257, 15.57834285, 15.58248717, 15.6771984 , 15.97459476,\n",
       "       15.49057101, 16.31062091, 15.67538969, 15.86862093, 15.94111339,\n",
       "       15.99781148, 15.29251938, 15.94520964, 15.74860533, 15.94414653,\n",
       "       15.79143678, 15.73863419, 15.61366896, 15.98997035, 15.93975354,\n",
       "       15.70188643, 15.78722292, 15.50647329, 15.70490847, 15.96392999,\n",
       "       15.90617309, 15.83608698, 16.16885537, 16.04572569, 15.89717943,\n",
       "       16.26146155, 16.08609368, 15.95622707, 15.90523957, 15.58955313,\n",
       "       15.88351823, 16.06374647, 15.78603247, 16.06877758, 15.90709857,\n",
       "       15.57282744, 16.09913258, 15.98958576, 15.55590782, 15.92496276,\n",
       "       15.78792302, 15.73557026, 15.75394336, 15.92682492, 16.05122095,\n",
       "       16.07583636, 15.67510223, 15.78797166, 15.83359498, 15.78440503,\n",
       "       15.98143531, 16.12458577, 15.61389244, 15.83132904, 15.78781637,\n",
       "       15.8602748 , 15.47270145, 15.70594063, 15.96756804, 15.74836879,\n",
       "       15.93038962, 15.7288413 , 16.1113805 , 16.10656494, 16.20053224,\n",
       "       16.05665526, 15.78799995, 15.70375593, 15.84861434, 15.623638  ,\n",
       "       15.70843098, 15.81807086, 15.81927128, 16.10598973, 15.38538191,\n",
       "       15.916745  , 15.64266645, 15.75713023, 16.0162953 , 15.70746105,\n",
       "       15.64366068, 15.91419746, 15.88949663, 15.61693071, 16.02228876,\n",
       "       15.92617221, 15.84368557, 15.9805507 , 16.13213599, 15.82215483,\n",
       "       15.51914111, 16.03094464, 16.11988159, 15.65737766, 15.5157206 ,\n",
       "       15.45746296, 15.96455401, 15.36352303, 15.88978918, 16.27718233,\n",
       "       16.05384193, 15.36399385, 15.82778876, 15.77564191, 16.13864772,\n",
       "       15.70607459, 15.95029043, 15.81338521, 16.23595649, 15.83985486,\n",
       "       16.35597366, 15.61431123, 15.80549231, 15.9595517 , 15.69566811,\n",
       "       15.96361356, 15.66106453, 16.03376676, 16.26075867, 15.7080053 ,\n",
       "       15.68688005, 15.60365119, 15.64739521, 15.60832718, 15.89471467,\n",
       "       16.23906254, 16.11794068, 15.819176  , 15.96595353, 16.10570834,\n",
       "       16.19657112, 16.20377038, 16.16782393, 15.82750828, 15.84126644,\n",
       "       15.88965986, 16.1107285 , 16.23383504, 15.46313571, 15.81268663,\n",
       "       15.88702444, 16.04053998, 15.3637303 , 15.6551543 , 15.93052999,\n",
       "       15.9632599 , 15.95838581, 15.55422535, 16.08516497, 16.22557908,\n",
       "       16.05516166, 15.54769506, 15.66195471, 15.71856833, 15.52228712,\n",
       "       16.17336581, 15.7032904 , 15.80228459, 15.96152129, 15.97928078,\n",
       "       15.74555019, 15.93447796, 15.41194297, 16.1235573 , 16.02265169,\n",
       "       15.68190462, 15.90332025, 15.81550975, 15.99036575, 15.68121183,\n",
       "       16.11464539, 15.94432692, 15.98329282, 15.76462582, 15.78286348,\n",
       "       15.70994903, 16.11783266, 15.36213418, 15.95415079, 15.752457  ,\n",
       "       15.99367412, 16.00470835, 16.26862524, 15.91250087, 15.94153831,\n",
       "       15.41348364, 15.6302792 , 16.14133551, 15.74376672, 15.81124661,\n",
       "       15.77406021, 15.49823083, 15.88651173, 16.00447959, 16.09504041,\n",
       "       15.28277929, 15.80584942, 15.76606728, 15.60586601, 15.18190939,\n",
       "       16.04593763, 15.65819858, 15.9175866 , 16.19196744, 15.84393979,\n",
       "       16.02728793, 15.99373502, 16.05716111, 16.02433448, 16.01704892,\n",
       "       15.94187677, 15.69668754, 15.83492701, 15.76548106, 15.82523061,\n",
       "       15.61492349, 15.94599204, 16.05087105, 16.00825977, 15.89366543,\n",
       "       15.44327999, 15.5764087 , 15.62862884, 15.58828989, 15.93279099,\n",
       "       15.74349333, 15.91609646, 15.45687523, 15.99411326, 15.7166989 ,\n",
       "       15.64206801, 15.83366864, 15.89280884, 15.94910122, 15.61313948,\n",
       "       15.93564801, 16.01675034, 15.6129754 , 15.5760166 , 16.08318567,\n",
       "       15.94242867, 15.77387824, 15.78930726, 15.59335026, 15.75069818,\n",
       "       15.58063115, 15.87182139, 15.81411276, 16.1124318 , 16.24827026,\n",
       "       15.45081962, 15.87667649, 15.86565327, 15.43825777, 15.92027728,\n",
       "       15.51027909, 15.68530557, 15.88938797, 15.90767609, 16.25309973,\n",
       "       16.05586395, 15.73714929, 15.96314227, 16.36735714, 16.26219156,\n",
       "       15.62284294, 15.86780417, 16.20878795, 15.94261396, 15.89474286,\n",
       "       16.01467818, 16.05942508, 15.78518918, 15.95221717, 15.63143895,\n",
       "       16.0204327 , 15.92315742, 15.94363248, 16.17033717, 15.90480068,\n",
       "       15.98746181, 15.95949076, 15.87121867, 15.93481951, 15.86948585,\n",
       "       15.61023483, 16.15395137, 16.36541275, 16.14380958, 15.47564995,\n",
       "       15.46836854, 15.68465726, 15.51170366, 15.53608715, 15.59497514,\n",
       "       15.86536314, 15.74495671, 15.86112645, 15.58166431, 15.72175222,\n",
       "       15.40073665, 15.79873428, 15.8163305 , 15.9781994 , 15.75365872,\n",
       "       15.87817031, 15.90888826, 15.81163421, 16.18371998, 15.90338125,\n",
       "       15.52404061, 16.02317999, 16.09870439, 15.94130524, 15.922375  ,\n",
       "       16.17067257, 16.06459802, 16.28766206, 15.85816653, 15.90864629,\n",
       "       16.06048878, 16.16303823, 16.07131096, 15.57356083, 16.19836066,\n",
       "       15.98395894, 16.11265399, 16.20784349, 15.70673908, 15.70580897,\n",
       "       15.86719781, 15.36494466, 15.6922976 , 15.90062505, 16.23119912,\n",
       "       16.20224741, 16.05867798, 15.69402988, 15.69338333, 15.85956729,\n",
       "       16.21818887, 15.18097343, 15.76663443, 15.64319807, 15.71861352,\n",
       "       15.58092496, 15.85703772, 15.76351232, 15.62227178, 15.92783593,\n",
       "       16.00115674, 16.31985374, 16.05170734, 16.43002192, 15.82002254,\n",
       "       15.98624099, 15.65497642, 15.77597687, 16.05237426, 15.57344354,\n",
       "       15.633251  , 16.05610031, 16.29526011, 15.81210893, 15.78707609,\n",
       "       15.99097108, 15.79395256, 16.07702797, 16.09082897, 16.05483381,\n",
       "       15.72424109, 15.70013472, 15.62331216, 15.75209965, 15.59055274,\n",
       "       15.82194277, 15.71015806, 16.29565789, 15.89685091, 15.76524904,\n",
       "       16.14489012, 15.88031452, 15.83884621, 15.75516908, 15.89305382,\n",
       "       16.03451818, 15.87399248, 15.69697178, 15.7928201 , 16.21057603,\n",
       "       15.66621026, 16.15945872, 15.78203485, 15.71622623, 16.2696442 ,\n",
       "       15.95427189, 15.9188416 , 15.63946033, 15.90785615, 15.71163118,\n",
       "       15.67704541, 16.09386675, 15.68438266, 15.83919326, 15.70001947,\n",
       "       15.987165  , 15.6349392 , 15.74380103, 15.5170247 , 15.99489013,\n",
       "       15.80078016, 15.584046  , 15.74289128, 15.65242137, 16.07280448,\n",
       "       15.61298166, 15.79477724, 15.58506203, 15.82801353, 16.37762534,\n",
       "       15.54740108, 15.6219171 , 15.9974207 , 15.56427754, 15.77101227,\n",
       "       15.46395259, 15.79997063, 16.18568166, 16.13925883, 15.78523004,\n",
       "       15.78132232, 15.95082309, 15.79180445, 15.70797253, 15.48518752,\n",
       "       16.19437159, 15.44037443, 15.44462738, 15.90360459, 15.64116084,\n",
       "       15.97959459, 15.7229572 , 15.50514338, 15.99802181, 15.61557835,\n",
       "       15.77600883, 15.69995341, 15.98761341, 16.09440925, 16.28589034,\n",
       "       15.98111914, 15.95874548, 16.3573551 , 15.44571972, 15.61905808,\n",
       "       15.75853984, 15.72963846, 15.86773874, 15.86915473, 16.20822188,\n",
       "       16.00403459, 16.02305493, 15.86133433, 16.17146413, 15.80013253,\n",
       "       16.01421591, 15.7739532 , 15.79036138, 15.82301396, 16.32884216,\n",
       "       16.05075649, 15.90093173, 15.50901597, 16.1150931 , 15.69984977])"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lasso.predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
